#include<bits/stdc++.h>

#define rp(i,a,b) for(int i=a;i<b;++i)
#define rrp(i,b,a) for(int i=b;i>=a;--i)

using namespace std;

int main(){
	int n;scanf("%d", &n);
	int a[100];
	rp(i , 0 , 100){a[i] = 0;}
	rp(i , 0 , n){
		int num;scanf("%d", &num);
		if(num == 1){
			rp(j , 0 , 100){
				if(a[j] == 0){
					a[j] = 1;
					printf("%d\n", j + 1);
					break;
				}
			}
			continue;
		}
		int cnt = 0,cnt2 = 0, yes = 0;
		for (int j = 0; j < 100; j += 5)
		{	
			rp(z , j , j + 5)
			if(a[z] == 0){
				int k = z + 1;
				while(k<j+5 && a[k] == 0){
					++k;
				}
				if(k - z >= num){
					yes = 1;
					rp(x , z , z + num){
						a[x] = 1;
						printf("%d%c", x + 1,x==z+num-1?'\n':' ');
					}
					break;
				}	
			}
			if(yes)break;
		}
		if(!yes){
			rp(j , 0 , 100){
				if(a[j] == 0){
					a[j] = 1;
					printf("%d", j+1);
					--num;
					if(num){
						printf(" ");
					}else{
						printf("\n");
						break;
					}
				}
			}
		}
	}
	
	return 0;
}